package com.lwphk.easydocs.ui;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletResponse;

import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.lwphk.easydocs.core.vo.DocsBasicInfo;

@Controller
public class DocsUIController {

	@RequestMapping("/easy-docs.ui")
	public void ui(ServletResponse response) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("data", JSON.toJSONString( DocsBasicInfo.DocsInfo.getDocData(),SerializerFeature.WriteMapNullValue));
		params.put("applicationName", "Jfinal-DOCS-UI");
		try {
			String html = HTMLTemplateUtils.render(new ClassPathResource("ui.html").getInputStream(), params);
			response.setContentType("text/html; charset=UTF-8");
			response.getWriter().write(html);
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		
		
	}
}
